<?php
    print $MAINMENU;
    /*$CURID = $this->uri->segment(3);
    $TYPES = $this->db->get('types')->result_array();
    print '<ul>';
    array_shift(&$MAINMENU);
    foreach($MAINMENU as $node) {
        print '<li>'.anchor($TYPES[$node['type_id'] - 1]['typename'].'/view/'.$node['id'], $node['title']);

        if($node['id'] == $CURID) {
            $sub = $this->tree->getTree($CURID);
            if(count($sub) > 0) {
                print '<ul>';
	            foreach($sub as $nd) {
                    print '<li>'.anchor($TYPES[$nd['type_id'] - 1]['typename'].'/view/'.$nd['id'], $nd['title']);
	            }
	            print '</ul>';
            }
        }
    }
    print '</ul>';
    /*print '<ul>';
    foreach($MAINMENU as $item) {
        $lastlevel = $item['level'];
        if($item['level'] <= $lastlevel) {
            print '<li>'.$item['title'];
        } else {
            print '<ul>';
                print '<li>'.$item['title'];
            print '</ul>';
            $lastlevel = $item['level'];
        }
    }
    print '</ul>';*/

    //print nl2br(print_r($MAINMENU, true));

	//print nl2br(print_r(normolize($MAINMENU, 1), true));


    //$this->load->model('Menu');
    //print nl2br(print_r($MAINMENU, true));
    /*$TREE = $this->db->where('active', 1)
    ->where('parent_id <> 0')
    ->get('tree')->result_array();
    $TYPES = $this->db->get('types')->result_array();

    print '<ul>';
    foreach($TREE as $item) {

        if($item['parent_id'] == 1) {
            print '<li>'.anchor($TYPES[$item['type_id']-1]['typename'] . '/view/' . $item['id'], $item['title']);
        }

        if($this->uri->segment(3) == $item['id'] && $item['is_default'] != 1) {
            $query = $this->db->where('active', 1)->where('parent_id', $item['id'])->get('tree');
            if($query->num_rows() == 0) {
                $query = $this->db->where('active', 1)->where('parent_id', $item['parent_id'])->get('tree');
            }

            $childs = $query->result_array();
            if(count($childs) > 0) {
                //print '<ul>';
                foreach($childs as $child) {
                    if($child['parent_id'] != 1) {
                        print '<br />'.nbs(4).'<img src="/assets/images/arrow.gif">'.anchor($TYPES[$item['type_id']-1]['typename'] . '/view/'.$child['id'], $child['title']);
                    }
                }
                //print '</ul>';
            }
        }
    }
    print '</ul>';*/
?>